package com.sunmi.sbs.commons.utils;

import org.apache.commons.text.RandomStringGenerator;


public class RandomUtils {
    public static String generateWithCommons(int length) {
        // 基础字符生成器
        RandomStringGenerator baseGenerator = new RandomStringGenerator.Builder()
                .withinRange('0', 'z')
                .filteredBy(Character::isLetterOrDigit)
                .build();

        // Emoji 生成器（简化版）
        RandomStringGenerator emojiGenerator = new RandomStringGenerator.Builder()
                .withinRange(0x1F600, 0x1F64F)
                .build();

        StringBuilder result = new StringBuilder();
        for (int i = 0; i < length; i++) {
            // 70% 概率生成基础字符，30% 概率生成 Emoji
            if (Math.random() < 0.7) {
                result.append(baseGenerator.generate(1));
            } else {
                result.append(emojiGenerator.generate(1));
            }
        }
        return result.toString();
    }
}



